<div class="layui-card-body ">
    <form id="profile" style="margin-top: 15px;" class="layui-form" action="{{route('admin.member.create.attach.1')}}">
        @csrf
        <div class="layui-form-item">
            <label class="layui-form-label">证件照</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="thumb">上传图片</button>
                    <div class="layui-upload-list">
                        @if(empty($data['id_photo']))
                            <img class="layui-upload-img" id="pic" width="100" height="100">
                            @else
                            <img class="layui-upload-img" src="/{{$data['id_photo']}}" id="pic" width="100" height="100">
                        @endif
                        <p id="demoText"></p>
                        <input type="hidden" name="id_photo" value="{{$data['id_photo']}}">
                    </div>
                    <div style="width: 95px;">
                        <div class="layui-progress layui-progress-big" lay-showpercent="yes" lay-filter="progress">
                            <div class="layui-progress-bar" lay-percent=""></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="hidden" name="id" value="{{request('user_id')}}">
                <input type="text" name="truename" autocomplete="off" value="{{$data['truename']}}"  placeholder="请输入真实姓名"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-block">
                <input type="text" name="idcard" autocomplete="off" value="{{$data['idcard']}}"  placeholder="请输入身份证号"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="male" title="男" @if($data['sex'] == "male" || empty($data['sex']))checked=""@endif>
                <input type="radio" name="sex" value="female" title="女" @if($data['sex'] == "female")checked=""@endif>
                <input type="radio" name="sex" value="secret" title="其他" @if($data['sex'] == "secret")checked=""@endif>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
                <input type="text" name="birthday" autocomplete="off" value="{{$data['birthday']}}" id="birthday" placeholder="请选择生日"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">城市</label>
            <div class="layui-input-block">
                <input type="text" name="city" autocomplete="off" value="{{$data['city']}}"  placeholder="请输入城市"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">学历</label>
            <div class="layui-input-block">
                <input type="text" name="education" autocomplete="off" value="{{$data['education']}}"  placeholder="请输入学历"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">职位</label>
            <div class="layui-input-block">
                <input type="text" name="job" autocomplete="off" value="{{$data['job']}}"  placeholder="请输入职位"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">签名</label>
            <div class="layui-input-block">
                <textarea name="signature" class="layui-textarea" rows="3">{{$data['signature']}}</textarea>
            </div>
        </div>
    </form>
</div>
<script src="{{asset('layui/modules/xm-select.js')}}"></script>
<script src="{{asset('js/tree/select.js')}}"></script>
<script>
    var idx = -1;
    layui.use(['xmSelect','upload','element','form','upload','laydate'], function () {
        var xmSelect = layui.xmSelect,
            element = layui.element,upload = layui.upload,laydate = layui.laydate;
        laydate.render({
            elem: '#birthday'
            ,type: 'date'
        });
        var uploadInst = upload.render({
            elem: '#thumb'
            ,url: '{{route('admin.member.create.attach')}}'
            ,field: "img"
            ,before: function(obj){
                obj.preview(function(index, file, result){
                    $('#pic').attr('src', result); //图片链接（base64）
                });
                element.progress('progress', '0%'); //进度条复位
                layer.msg('上传中', {icon: 16, time: 0});
            }
            ,data: {"_token": "{{csrf_token()}}","path": "member"}
            ,done: function(res){
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                $('#demoText').html('');//置空上传失败的状态
                $('input[name="id_photo"]').val(res.path);
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            //进度条
            ,progress: function(n, elem, e){
                element.progress('progress', n + '%');
                if(n == 100){
                    layer.msg('上传完毕', {icon: 1});
                }
            }
        });
    });
</script>

